package main

import (
	"context"
	"fmt"
	"github.com/docker/docker/api/types"
	"github.com/docker/docker/client"
	. "go_learn/constant"
)

func FindContainer(host string, filterName string) {
	//args := filters.NewArgs()
	//args.Add("name", filterName)
	listOptions := types.ContainerListOptions{
		All: true,
		//Filters: args,
	}
	host = "http://" + host + DOCKER_API_PORT
	cli, err := client.NewClient(host, DOCKER_API_VERSION, nil, nil)
	if err != nil {
		fmt.Println(err)
	}
	containerList, err := cli.ContainerList(context.Background(), listOptions)
	for _, container := range containerList {
		fmt.Println(container.ID)
	}
}
func main() {
	host := "20.26.38.124"
	FindContainer(host, "etcd")
}
